/*Ext.onReady(function() {
	// 用户信息
	new Ext.Panel({
		title : 'User Info',
		width : 250,
		height : 200,
		margins : '0 0 0 0',
		cmargins : '0 0 0 0',
		renderTo : 'homepage_userInfo_panel',
		html : 'adfd'
	});
	
	// 系统通告
	new Ext.Panel({
		title : 'System Notice',
		width : 250,
		height : 200,
		margins : '0 0 0 0',
		cmargins : '0 0 0 0',
		renderTo : 'homepage_notice_panel',
		html : 'adfd'
	});
});*/

DC.front.HomePagePanel = function(config) {
	var homePanel = this;
	var welcome_html = '<div class="welcom">' 
		+ '<h2 class="welcom_tip">欢迎使用Java IDE简易的PaaS平台</h2>'
		+ '<div class="left_txt tip"><img src="image/ts.gif" width="16" height="16">&nbsp;系统公告：</div>'
		+ '<div class="left_txt">'
		+ '<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1、<span class="left_ts"></span></p>'
		+ '<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2、</p>'
		+ '<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3、</p>'
	    + '</div>'
	    + '</div>';
	
	this.welcome = new Ext.Panel({
		height : 200,
		anchor : '100%',
		margins : '0 0 0 0',
		cmargins : '0 0 0 0',
		border : false,
		header : false,
		html : welcome_html
	});
	// 用户信息
	this.userInfo_panel = new Ext.Panel({
		title : '<div style="float:left;">User Info</div><div style="float:right;"><a href="javascript:void(0);" id="homepage_modify_userInfo_icon"><img src="././image/ico_user_edit.png" alt="Modify User Info" /></a><a href="javascript:void(0);" id="homepage_modify_password_icon" style="margin-left:10px;"><img src="././image/ico_password_edit.png"  alt="Modify Password" /></a></div>',
		anchro :'100%',
		minHeight : 200,
		maxHeight : 400,
		anchor : 'r b',
		margins : '0 0 0 0',
		cmargins : '0 0 0 0',
		listeners: {
        	afterRender: function() { // 当窗口渲染完成后执行
        		Ext.Ajax.request({
        		    url : DC.url.GET_CURRENTUSERINFO,
        		    method : 'POST',
        		    success : function(response, options){
        			    var res = Ext.util.JSON.decode(response.responseText);
        			    var obj = res.user;
        			    DC.action.SysAction.initUserInfo(obj);
        			    homePanel.updateUserInfo();
        		    },
        		    failure : function(response, options){
        		    	flag = false;
        		    }
        	    });
        	}
        }
	});
	
	// 系统通告
	this.sys_notice_panel = new Ext.DatePicker({
		//width : 250,
		//height : 200,
		anchor : 'r b',
		margins : '0 0 0 0',
		cmargins : '0 0 0 0',
		style : 'margin-top:20px;'
	});
	DC.front.HomePagePanel.superclass.constructor.call(this, Ext.apply({
		id: 'editor_tabPanel_homePage',
		title : 'Home',
		iconCls : 'welcome_icon',
		hideMode :'offsets',
		margins : '0 0 0 0',
		cmargins : '0 0 0 0',
		style : 'padding:10px 10px;',
        loadMask : false,
        closable : false,
        header : false,
		border : false,
		closable : false,
		border : false,
		autoScroll : true,
		layout: 'border',
		defaults : {
			border : false
		},
		items : [{
			region : 'center',
			layout : 'anchor',
			bodyStyle : 'padding-right:20px;',
			items : [this.welcome]
		}, {
			region : 'east',
			width : 260,
			layout : 'anchor',
			items : [this.userInfo_panel, this.sys_notice_panel]
		}]
		
	}, config || {}));
};

Ext.extend(DC.front.HomePagePanel, Ext.Panel, {
	updateUserInfo : function() {
		var notes = 'No message';
	    if (DC.front.variable.SYS_CURRENTUSER.notes != '') {
	    	notes = DC.front.variable.SYS_CURRENTUSER.notes;
	    }
	    var tpl = new Ext.XTemplate(  
		    '<div class="user_info">',  
		      '<table>',
			    '<tr><td class="label">Current User：</td><td><font color="red">' + DC.front.variable.SYS_CURRENTUSER.username +'</font><td></tr>',
			    '<tr><td class="label">Current Integral：</td><td>' + DC.front.variable.SYS_CURRENTUSER.point +'<td></tr>',
			    '<tr><td class="label">Login Times：</td><td>' + DC.front.variable.SYS_CURRENTUSER.loginTimes +'<td></tr>',
	 		    '<tr><td class="label">Last Login Time：</td><td>' + DC.front.variable.SYS_CURRENTUSER.lastSignTime +'<td></tr>',
	 		    '<tr><td class="label" valign="top">Notes：</td><td>' + notes +'<td></tr>',
			  '</table>',
	        '</div>'
		);
		tpl.compile();
		tpl.overwrite(this.userInfo_panel.body, null);
	}
});